import { createRouter, createWebHashHistory, createWebHistory } from "vue-router";

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: "/login",
      name: "login",
      component: () => import("@/views/Login.vue"),
    },
    // 匹配不存在的页面
    {
      path: "/:pathMatch(.*)",
      redirect: {
        path: "login"
      }
    }
  ]
});

router.beforeEach((to, from, next) => {
  if (to.name === 'login') {
    next()
  } else {
    next()
  }
})

export default router;
